<?php

namespace Domain\Task;

/**
 * Class CalendarDate
 *
 * Value Object
 */
class CalendarDate {

    /**
     * @var DateTime
     */
    private $oDate;

    /**
     * The format of the string that will be returned by the DateTime object.
     *
     * @var string http://nl3.php.net/manual/en/function.date.php
     */
    protected static $sDateTimeFormat = 'Y-m-d H:i:s';

    /**
     * Has a composition relationship with the DateTime class
     * 
     * @param \DateTime $dateTime
     */
    public function __construct(\DateTime $dateTime) {
        $this->oDate = $dateTime;
    }

    /**
     * Only classes that extend CalendarDate can use the DateTime ($oDate)
     * object, only these objects will allowed to make changes or calculations
     * on the DateTime object.
     *
     * @return DateTime
     */
    protected function getDate() {
        return $this->oDate;
    }

    /**
     * Returns a formatted string based on the date.
     *
     * @return string
     */
    public function toString() {
        return (string) $this->oDate->format(self::$sDateTimeFormat);
    }

}

?>
